C (187/301)

From:Ben Hutchings
Date:15 Aug 99 at 01:24:19
Subject:Re: How do a get the current time/date without using ReadBattClock()

From: Ben Hutchings <womble@zzumbouk.demon.co.uk>

On Fri, Aug 13, 1999 at 10:58:51PM +0000, Dominic Clifton wrote:
> From: Dominic Clifton <dominicc@barrysworld.co.uk>
>
>
> How do you get the current time/data in packed format without
> using the ReadBattClock() function ?
>
> (The result must bea ULONG containing the seconds since Jan 1, 1978, not
> Jan 1, 1970)
>
> HELP!!

1. Use timer.device:

struct Device * TimerBase;
struct timeval tvNow;

/* open timer.device with request ioTimer */
TimerBase = ioTimer.io_Device;

GetSysTime(&tvNow);

/* number of seconds since 1978/1/1 is tvNow.tv_secs */

2. Use DOS:

struct DateStamp ds;
DateStamp(&ds);

/* number of seconds since 1978/1/1 is
ds.ds_Days*86400 + ds.ds_Minute*60 + ds.ds_Tick/TICKS_PER_SECOND */

Number 1 should be a bit faster, but number 2 is obviously easier.



Ben Hutchings - womble@zzumbouk.demon.co.uk, http://www.zzumbouk.demon.co.uk
Team *AMIGA* | Jay Miner Society | Linux - the choice of a GNU generation
Life is like a sewer:
what you get out of it depends on what you put into it.